<template>
    <div class="edu-page-warp">
        <el-card shadow="never" body-style="padding: 24px;">
            <div slot="header" class="clearfix">
                <span class="edu-page-title" style="font-weight: normal;">课程考核方式详情</span>
                <el-button style="float: right; padding: 3px 0" type="text" @click='goBack'>返回</el-button>
            </div>
            <div>
                <el-form label-width="70px">
                    <el-row :gutter="40">
                      <el-col :span="7">
                            <el-form-item :label="$t('label.courseCode') + ':'">
                                <el-input
                                    style="width: 100%"
                                    v-model="queryForm.condition"
                                    :disabled="true" />
                            </el-form-item>
                      </el-col>
                      <el-col :span="7">
                        <el-form-item :label="$t('label.courseName') + ':'">
                            <el-input
                                style="width: 100%"
                                v-model="queryForm.courseName"
                                :disabled="true" />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-form>
            </div>
            <div class="clearfix">
                <div class="float-right" style="margin-bottom: 16px;">
                    <el-button type="primary" @click="exportFn">{{$t("message.export")}}</el-button>
                </div>
            </div>
            <edu-table :data="tableData" :order="false" :pageNum="page.pageNum_" :selection="false"
                :pageSize="page.pageSize_" :total="page.total_" @page-change="pageChange" ref="courseTable">
                <edu-table-column :label="$t('label.grade')"  prop="grade"></edu-table-column>
                <edu-table-column :label="$t('label.college')"  prop="faculty"></edu-table-column>
                <edu-table-column :label="$t('label.major')"  prop="profession"></edu-table-column>
                <edu-table-column label="考核方式"  prop="assessmentMode"></edu-table-column>
            </edu-table>
        </el-card>
    </div>
</template>
<script>
    import {findCoursesAssessmentMode} from 'common/src/api/culture/bachelor';
    export default {
        name: 'assessment-method-detail',
        data() {
            return {
                queryForm: {
                    term: '',
                    grade: '',
                    condition: '',
                    courseName: ''
                },
                tableData: [],
                page: {
                    pageNum_: 1,
                    pageSize_: 20,
                    total_: 0
                }
            }
        },
        created() {
            let params = this.$route.params || {};
            Object.assign(this.queryForm, params);
            this.search();
        },
        methods: {
            search({pageSize, pageNum} = {}) {
                let param = {
                    pageNum_: pageNum || this.page.pageNum_,
                    pageSize_: pageSize || this.page.pageSize_,
                    grade: this.queryForm.grade,
                    term: this.queryForm.term,
                    condition: this.queryForm.condition,
                    projId: 1,
                }
                findCoursesAssessmentMode(param).then(res => {
                    if (res && res.code === 200) {
                        let data = res.data || [];
                        this.tableData = data.list || [];
                        this.page.pageNum_ = data.pageNum_;
                        this.page.pageSize_ = data.pageSize_;
                        this.page.total_ = data.total_;
                    }
                })
            },
            pageChange(pageOption) {
                this.search(pageOption);
            },
            exportFn() {
                window.location.href = 
                        '/api/cultureservice/bclCourses/exportCoursesAssessmentMode?grade='+this.queryForm.grade
                        +'&term='+this.queryForm.term+'&condition='+this.queryForm.condition+
                        '&projId=1'+'&name='+this.queryForm.courseName
            },
            goBack() {
                this.$store.commit('delete_tabs', this.$route.path);
                this.$router.push({
                    path: '/pyAssessmentMethodDetection'
                })
            }
        },
        beforeRouteLeave (to, from, next) {
            this.$store.commit('delete_tabs', this.$route.path);
            next();
        }
    }


</script>